package com.txsj.scan.widget;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;

/**
 * Created by wwb on 2016/9/27.
 * 自定义的TextView  使其支持字体库
 * 使用ttf字体库替代替图片
 *  https://blog.csdn.net/cn_1937/article/details/79077645
 */
public class TextViewFont extends TextView {


    public TextViewFont(Context context) {
        super(context);
        init(context);
    }

    public TextViewFont(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public TextViewFont(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        AssetManager assetManager = context.getAssets();
        Typeface font = Typeface.createFromAsset(assetManager, "fonts/iconfont.ttf");
        setTypeface(font);
    }

}
